//
//  System.h
//  CocoaSynth
//
//  Created by Pierre DUCHENE on 09/02/10.
//  Copyright 2010 Pierre DUCHENE. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "SynthKit.h"

/*!
    @class       System 
    @superclass  NSObject
    @abstract    This class is a Singleton. It enable all module have an access to usefull information.
    @discussion  Here is registered system sampleRate, ie the rate wich divide a sample
				 Usually it's 48 Khz or 96 Khz. 44,1 Khz is to few for quality sound.
				 With the sample rate, we have the pediod time: 1/sampleRate, and then with sampleSize
				 we can compute the sample duration: 
				 Furthermore System contain information about a sample, its size and the duration of a sample.
				 For instance, at 48 Khz if we want a sample wich during 1 millisecond
				 we need the sample size: 48000*0.001 = 48.
				 By default frequency = 48000Hz and sampleDuration = 0.001
*/
@interface System : NSObject {
	double sampleRate;		// "Frequence d'echantillonnage" in French ;)
	NSUInteger sampleSize;	// Size of a sample in number of value
	double sampleDuration;	// Duration in second of on sample
	double samplePosition;	// Position in a period T, it a double because duration between two point is not integer
	
	float time;			// Total duration of produced signal
	
	// ADSR infos
	float sustainDuration;
	float ADSRStartTime;			// Time at which ADSR envelope has begun
}

/*!
    @method     setFrequency:
    @abstract   Set the system sample rate
    @discussion We allow only three frequency: 48,96 and 192 Khz
	@param		aValue The Value of the new Frequency in Hertz
*/
@property (assign) double sampleRate;

/*!
    @method     setSampleSize
    @abstract   Set the system sample size
*/
@property (assign) NSUInteger sampleSize;

@property (readonly) double sampleDuration;
@property (assign) double samplePosition;
@property (readonly) float time;
@property (assign) float sustainDuration;
@property (assign) float ADSRStartTime;

+ (System*)sharedSystem;

- (void)newSampleProduced;

@end
